package com.example.demo.service;


import com.example.demo.common.AjaxResult;
import com.example.demo.entity.Personalinfo;
import com.example.demo.entity.SafeAnswerinfo;
import com.example.demo.entity.SafeQuestioninfo;
import com.example.demo.entity.Userinfo;
import com.example.demo.mapper.PersonalMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonalService {

    @Autowired
    private PersonalMapper personalMapper;

    public Personalinfo showPersonalInfo(Integer uid){
        return personalMapper.showPersonalInfo(uid);
    }

    //更新个人信息
    public int update(Personalinfo personalinfo) {
        return personalMapper.update(personalinfo);
    }

    //得到当前用户的密保问题
    public List<SafeQuestioninfo> getSafeQuestion(int uid,int i) {
        return personalMapper.getSafeQuestion(uid,i);
    }

    //得到当前用户的密保答案
    public List<SafeAnswerinfo> getAnswer(int uid) {
        return personalMapper.getAnswer(uid);
    }

    //根据uid qid查询有没有此密保答案
    public SafeAnswerinfo getAnswerByUidQid(SafeAnswerinfo answerinfo) {
        return personalMapper.getAnswerByUidQid(answerinfo);
    }


    //插入数据
    public int addAnswerByUidQid(SafeAnswerinfo answerinfo) {
        return personalMapper.addAnswerByUidQid(answerinfo);
    }

    //更新数据
    public int updateAnswerByUidQid(SafeAnswerinfo answerinfo) {
        return personalMapper.updateAswerByUidQid(answerinfo);
    }

    //更新密码
    public int updatePassword(String newpwd,Integer id) {
        return personalMapper.updatePassword(newpwd,id);
    }


    //注册是添加对应个人信息
    public int addPersonal(Userinfo userinfo) {
        return personalMapper.addPersonal(userinfo);

    }
}

